package com.Socket.Server;

import org.dom4j.io.SAXReader;

import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import java.util.ArrayList;



public class AnalysisXML {
    private final String inFilePath = "xml/Result1.xml";
    private Document document = null;

    public AnalysisXML() {
        try {
            this.document = new SAXReader().read(inFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public User insertInSQL() {
        Element root = null;
        List<User> users = new ArrayList<>();
        int index = 1;
        User temp =new User();
        try {
            temp.setPassword(document.selectSingleNode("//user/password/text()").getStringValue());
            temp.setUsername(document.selectSingleNode("//user/username/text()").getStringValue());

        } catch (Exception e) {
            System.out.println("xml文件解析出现错误");
            e.printStackTrace();
        }
        System.out.println(temp);
        return temp;
    }
}
